package br.com.spring.mvc.validator;

import org.springframework.validation.Errors;
import org.springframework.validation.ValidationUtils;
import org.springframework.validation.Validator;

import br.com.spring.mvc.entity.Simple;

public class SimpleValidator implements Validator {

	@Override
	public boolean supports(Class<?> clazz) {
		return Simple.class.equals(clazz);
	}

	@Override
	public void validate(Object target, Errors errors) {
		ValidationUtils.rejectIfEmpty(errors, "id", "id.empty", "N");
//		Simple simple = (Simple) target;
//        if (simple.getAge() < 0) {
//            e.rejectValue("age", "negativevalue");
//        } else if (simple.getAge() > 110) {
//            e.rejectValue("age", "too.darn.old");
//        }
	}

}
